package org.zn.mvcbase.response;

import java.util.Map;


/**
 * @ProjectName:91isoft_oa
 * @Description: 
 * @Copyright: Copyright (c) 2016

 * @author: 周楠
 * @date 2016年3月16日 上午10:21:41
 */

public class ResponseMessageFactory {
	
	private Map<String, DataConverter> convertermapper;
	

	public Map<String, DataConverter> getConvertermapper() {
		return convertermapper;
	}

	public void setConvertermapper(Map<String, DataConverter> convertermapper) {
		this.convertermapper = convertermapper;
		
	}


	public ResponseMessage getResponseMessage(Metadata metadata,Class<? extends ResponseMessage> rmclazz){
		
		ResponseMessage rm=null;
		try {
			rm = rmclazz.newInstance();
		} catch (InstantiationException | IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
	    DataConverter dc=convertermapper.get(rm.getMapperKey());
	    rm =dc.converter(metadata, rm);
		
		return rm;
		
	}
}
